package com.lanyuan.a.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lanyuan.a.atest.BaseFormMap;
import com.lanyuan.a.bean.Window;
import com.lanyuan.a.bean.WindowSale;
import com.lanyuan.a.dao.BaseDao;
import com.lanyuan.a.service.WindowService;
import com.lanyuan.plugin.PageView;
@Service("windowService")
public class WindowServiceImpl implements WindowService {
	@Resource
	public BaseDao<Window> baseDao;
	
	@Override
	public List<Window> list() {
		return baseDao.find("from Window");
	}

	@Override
	public List<Window> queryByPage(BaseFormMap formMap) {
		PageView pageView = (PageView)formMap.get("paging");
		int first = pageView.getPageNow();
		int max = pageView.getPageSize();
		
		String countHql = "select count (1) from Window";
		Long count = baseDao.count(countHql);
		pageView.setRowCount(count);
		return baseDao.find("from Window",new Object[]{},first , max);
	}

	@Override
	public List<Window> list(int cid) {
		return baseDao.find("from Window where c_id = ?" , new Object[]{cid});
	}

	@Override
	public Window get(int wid) {
		
		return baseDao.get("from Window where w_id = ?" , new Object[]{wid});
	}

}
